<?php


class RegisterView
{
	/**
	*@var string post
	**/
	private static $email = "RegisterView::email";
	/**
	*@var string post
	**/
	private static $username = "RegisterView::userName";
	/**
	*@var string post
	**/
	private static $password = "RegisterView::password";
	/**
	*@var string post
	**/
	private static $password2 = "RegisterView::password2";
	/**
	*@var string 
	**/
	private static $action = "register";

	/**
	*@var string css id
	**/
	private static $usernameTextField = "UsernameTextField"; 
	/**
	*@var string css id
	**/
	private static $formSubmitButton = "FormSubmitButton"; 
	/**
	*@var string css id
	**/
	private static $passwordTextField = "PasswordTextField";
	/**
	*@var string css id
	**/
	private static $password2TextField = "Password2TextField";

	/**
	*@param string post
	*@return string bodyhtml
	**/
	public function getRegisterPage($errorMessage)
	{
		$body = "";
		$body = $this->getRegisterPageHeader();
		$body .= $this->getRegisterForm($errorMessage);
		$body .= $this->getRegisterPageFooter();
		return $body;
	}

	/**
	*@return string html
	**/
	private function getRegisterPageHeader()
	{
		$header = "<h1>Träningsdagboken!</h1> <h2>Registrera en ny användare!</h2>";
		return $header;
	}
	

	/**
	*@var string message
	*@return string html
	**/
	private function getRegisterForm($message)
	{
		$email = $this->getEmail();
		$username = $this->getUsername();
		if($message != "")
		{
			$message = "<div id='ErrorMessageDiv'><p>$message</p></div>";
		}
		return "
		<div id='registerFormDiv' >
			<a href='index.php'>tillbaka</a>
			<form action='?".self::$action."' method='post' enctype='multipart/form-data'>
				<fieldset>
					$message
					<legend>Registrera - Skriv in Epost, Användarnamn och Lösenord</legend>
					<label for='" . self::$username . "' >Epost :</label>
					<input type='text' size='20' name='" . self::$email . "' id='" . self::$usernameTextField .  "' value='$email' />
					<label for='" . self::$usernameTextField . "' >Användarnamn :</label>
					<input type='text' size='20' name='" . self::$username . "' id='" . self::$usernameTextField . "' value='$username' />
					<label for='" . self::$passwordTextField . "' >Lösenord  :</label>
					<input type='password' size='20' name='" . self::$password . "' id='" . self::$passwordTextField . "' value='' />
					<label for='" . self::$password2TextField . "' >Lösenord  :</label>
					<input type='password' size='20' name='" . self::$password2 . "' id='" . self::$password2TextField . "' value='' />
					<input type='submit' name='' id='" . self::$formSubmitButton . "' value='Registrera' />
				</fieldset>
			</form>
		</div>";
	}


	/**
	*@return string html
	**/
	private function getRegisterPageFooter()
	{
		$footer = "<a>Robert Forsgren</a> <a>Träningsdagboken</a>" ;
		return $footer;
	}


	/**
	*@return string POST
	**/
	public function getEmail()
	{
		if(isset($_POST[self::$email]))
		{
			return $_POST[self::$email];
		}
		return "";
	}


	/**
	*@return string POST
	**/
	public function getUsername()
	{
		if(isset( $_POST[self::$username]))
		{
			return $_POST[self::$username];
		}
		return "";
	}

	/**
	*@return string POST
	**/
	public function getPassword()
	{
		if(isset($_POST[self::$password]))
		{
			return $_POST[self::$password];
		}
		return "";
	}


	/**
	*@return string POST
	**/
	public function getPassword2()
	{
		if(isset($_POST[self::$password2]))
		{
			return $_POST[self::$password2];
		}
		return "";
	}

}